<template>
  <div class="transaction-service-list bg-c-fff right-height mb70">
    <p class="bread rel">
      <a href="javascript:void(0);" class="font-s-16">交易监控师-客户纠错记录</a>
    </p>
    <div class="content">
      <table width="100%" class="auto">
        <tr>
          <th>提交时间</th>
          <th>订单编号</th>
          <th>客户名称</th>
          <th>联系方式</th>
          <th>订单详情</th>
          <th>纠错申请</th>
          <th>允许修改</th>
        </tr>
        <tr v-for="item in list">
          <td>{{item.createTime}}</td>
          <td>{{item.orderId}}</td>
          <td>{{item.customName}}</td>
          <td>{{item.customPhone}}</td>
          <td>
            <button class="blue-button small-btn-css" @click="onOrderClick(item)">查看订单</button>
          </td>
          <td>
            <button class="blue-button small-btn-css" @click="seeConClick(item)">查看内容</button>
          </td>
          <td>
            <button class="blue-button small-btn-css" @click="openModify(item)">{{item.errorStatue | ModifyFilter}}</button>
          </td>
        </tr>
      </table>
      <div class="fix foot-box">
        <div class="no-data-tip" v-show="list.length===0">暂无相关数据</div>
        <pagination :index="pageIndex" :total="pageTotal" v-show="this.list!=0" @pagechange="onPageChange"></pagination>
      </div>
    </div>
    <vodal :show="remarkShow" animation="zoom" :width="350" :height="260" @hide="remarkShow=false">
      <div class="vodal-main">
        <h4>客户纠错详情</h4>
        <div class="con">
          <p>纠错内容：
            <textarea class="vt" v-model="errorCon">
            </textarea>
          </p>
          <p>交易合同：
            <a :href="url" class="xl-btn-css blue-button">文件</a>
          </p>
        </div>
      </div>
    </vodal>
  </div>
</template>
<script type="text/javascript">
import Pagination from '../components/Pagination'
export default {
  components: {
    Pagination
  },
  data() {
    return {
      pageIndex: 1,
      pageTotal: 0,
      remarkShow: false,
      list: [],
      errorCon: '',
      url: ''
    }
  },
  mounted() {
    this.onPageChange(1)
  },
  methods: {
    onPageChange(n) {
      this.getData(n)
    },
    getData(n) {
      this.$http.post('/tradeError/query/trade/error', {
        errorState: 1,
        page: n,
        rows: 10
      }).then(data => {
        if (data.data.httpCode === 200) {
          this.pageIndex = n
          this.pageTotal = Math.ceil(data.data.total / 10)
          this.list = data.data.rows
          console.log(this.list)
        } else {
          console.log(data.data.msg)
          this.$toasted.show(data.data.msg)
        }
      }).catch(err => {
        console.log(err)
      })
    },
    onOrderClick(item) {
      if (item.errorStatue === 1) {
        this.$router.push('/tm-transaction-draw?type=errorType&id=' + item.orderId)
      } else if (item.errorStatue === 0) {
        this.$router.push('/tm-transaction-draw-finish?id=' + item.orderId)
      }
    },
    seeConClick(item) {
      this.errorCon = item.errorContent
      this.url = item.customFile
      this.remarkShow = true
    },
    openModify(item) {
      if (item.errorStatue === 0) {
        this.$http.post('/transactionMonitorSer/modify', {
          id: item.id
        }).then(data => {
          if (data.data.httpCode === 200) {
            this.$toasted.show('开启成功！')
            this.list.forEach((i) => {
              if (i.id === item.id) {
                i.errorStatue = 1
              }
            })
          } else {
            console.log(data.data.msg)
            this.$toasted.show(data.data.msg)
          }
        }).catch(err => {
          console.log(err)
        })
      }
    }
  },
  filters: {
    ModifyFilter(v) {
      if (v === 1) {
        return '已开启'
      } else if (v === 0) {
        return '开启'
      }
    }
  }
}

</script>
<style type="text/css" scoped>
.bread {
  padding-left: 20px;
  border-bottom: 1px solid #ddd;
}

.bread a {
  line-height: 45px;
}

.bread button {
  right: 10px;
  top: 8px;
}

.content {
  padding: 0 30px;
  margin-top: 30px;
}

.content .seach input,
.content .seach button {
  height: 35px;
  line-height: 35px;
}

.content .seach {
  padding: 20px 30px;
}

.content .seach button {
  margin-left: -5px;
}

.foot-box {
  padding: 35px 32px 15px 13px;
}

textarea {
  width: 236px;
  height: 125px;
  padding: 10px 8px;
}

.vodal-main .con p:nth-of-type(2) {
  margin-top: 20px;
}

</style>
